import {searchPage} from '../../api/sellOrderManage'
import pickerOptions from  '@/utils/date';
import {createSellOutRepository} from '../../api/sellOutRepository'



let sellOutRepository = {
    data() {
        return {
            //日期组件
            pickerOptions:pickerOptions,
            //table的list
            tableData: [],
            total:0,
            sellOrderList:[],
            orderTypeOptions:[
                {
                    value: '',
                    label: '全部'
                },
                {
                    value: '电话订单',
                    label: '电话订单'
                }, {
                    value: '网络订单',
                    label: '网络订单'
                }
            ],
            payWayOptions:[
                {
                    value: '',
                    label: '全部'
                },
                {
                    value: '货到付款',
                    label: '货到付款'
                }, {
                    value: '款到发货',
                    label: '款到发货'
                }
            ],
            businessTypeOptions:[
                {
                    value: '',
                    label: '全部'
                },
                {
                    value: '普通业务',
                    label: '普通业务'
                }, {
                    value: '号卡套餐',
                    label: '号卡套餐'
                }
            ],
            orderActionOptions:[
                {
                    value: '',
                    label: '全部'
                },
                {
                    value: '订购',
                    label: '订购'
                }, {
                    value: '换购',
                    label: '换购'
                }, {
                    value: '支付',
                    label: '支付'
                }
            ],
            orderStateOptions:[
                {
                    value: '',
                    label: '全部'
                },
                {
                    value: '审核通过',
                    label: '审核通过'
                }, {
                    value: '待出库',
                    label: '待出库'
                }, {
                    value: '已出库',
                    label: '已出库'
                }, {
                    value: '已发货',
                    label: '已发货'
                }, {
                    value: '已到货',
                    label: '已到货'
                }, {
                    value: '已归档',
                    label: '已归档'
                }
            ],
            searchParams:{
                sellCode:"",
                orderState:"待出库",
                orderType:'',
                payWay:'',
                businessType:'',
                orderAction:'',
                currentPage :1,
                pageSize:5
            }
        };
    },
    methods:{
        //复选框的change事件，删除和修改拿到id
        checkBoxSelectionChange(row){
            this.sellOrderList = row;
        },
        currentPageChange(currentPage){
            this.searchParams.currentPage = currentPage;
            this.findPage();
        },
        //每页条数变化
        sizeChange(pageSize) {
            this.searchParams.pageSize = pageSize;
            this.findPage();
        },
        async findPage(){
            let response =  await searchPage(this.searchParams);
            this.total= response.total;
            this.tableData = response.records;
        },
        chooseTime(){
            this.searchParams.startTime=this.pickerOptions.startArrayDate[0];
            this.searchParams.endTime=this.pickerOptions.startArrayDate[1];
        },
        //路径未修改
        checkDetail(sellCode){
            this.$router.push("/sellOutRepositoryDetail/" + sellCode);
        },
        async createSellOutRepositoryOrder(){
            let sellCodeList = [];
            this.sellOrderList.forEach(value =>{
                sellCodeList.push(value.sellCode);
            });
            let response = await createSellOutRepository(sellCodeList);
            alert(response);
        }
    },
    created(){
        this.findPage();
    }
};

export default sellOutRepository;